package business_logic.view;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

import fiuba.algo3.titiritero.dibujables.SuperficiePanel;
import fiuba.algo3.titiritero.modelo.SuperficieDeDibujo;

public class Image implements ViewResource
{

    private BufferedImage m_image;
    
    Image( String imagePath )
    {
        try
        {
            URL imageURL = Class.class.getResource(imagePath);
            m_image = ImageIO.read( imageURL );
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }

    @Override
    public void draw(int x,int y,SuperficieDeDibujo graphicSurface)
    {
        ((SuperficiePanel)graphicSurface).getBuffer().drawImage( m_image, x, y, null );
    }

    public void draw(int x,int y, int width, int height, Graphics graphicSurface)
    {
        graphicSurface.drawImage( m_image, x, y, width, height, null );
    }
    
    public BufferedImage getBufferedImage()
    {
        return m_image;
    }
    
}
